<template>
  <div>
    <div class="shopinfo-header" v-if="Object.keys(shop).length !== 0">
      <img :src="'http:' + shop.logo" alt="" />
      <span>{{ shop.name }}</span>
    </div>

    <div class="shop-middle">
      <div class="shop-middle-item shop-middle-left">
        <div class="info-sells">
          <div class="sells-count">
            {{ shop.sells | sellCountFilter }}
          </div>
          <div class="sells-text">总销量</div>
        </div>

        <div class="info-goods">
          <div class="goods-count">
            {{ shop.goodsCount }}
          </div>
          <div class="goods-text">全部宝贝</div>
        </div>
      </div>

      <div class="shop-middle-item shop-middle-right">
        <table>
          <tr v-for="(item, index) in shop.score" :key="index">
            <td>{{ item.name }}</td>
            <td class="score" :class="{ 'score-better': item.isBetter }">
              {{ item.score }}
            </td>
            <td class="better" :class="{ 'better-more': item.isBetter }">
              <span>{{ item.isBetter ? "高" : "低" }}</span>
            </td>
          </tr>
        </table>
      </div>
    </div>

    <div class="shop-bottom">
      <div class="enter-shop">进店逛逛</div>
    </div>
  </div>
</template>
<script>
export default {
  name: "DetailShopInfo",
  props: {
    shop: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  filters: {
    sellCountFilter: function(value) {
      if (value < 10000) return value;
      return (value / 10000).toFixed(1) + "万";
    }
  }
};
</script>
<style scoped>
.shopinfo-header {
  display: flex;
  align-items: center;
  margin: 30px 7px 20px;
  font-size: 20px;
}

.shopinfo-header span {
  margin-left: 10px;
}

.shopinfo-header img {
  width: 60px;
  height: 60px;
  border: 1px solid lightgray;
  border-radius: 50px;
}

.shopinfo-body {
  display: flex;
}

.shop-middle-item {
  flex: 1;
}

.shop-middle {
  display: flex;
  align-items: center;
}

.sells-text,
.goods-text {
  font-size: 14px;
  color: black;
}

.shop-middle-left {
  display: flex;
  justify-content: space-evenly;
  text-align: center;
  font-size: 24px;
  color: black;
  border-right: 1px solid rgba(0, 0, 0, 0.1);
}

.shop-middle-right {
  font-size: 13px;
  color: #333;
}

.shop-middle-right table {
  width: 120px;
  margin-left: 30px;
}

.shop-middle-right table td {
  padding: 5px 0;
}

.shop-middle-right .score {
  color: #5ea732;
}

.shop-middle-right .score-better {
  color: #f13e3a;
}

.shop-middle-right .better span {
  background-color: #5ea732;
  color: #fff;
  text-align: center;
}

.shop-middle-right .better-more span {
  background-color: #f13e3a;
}

.shop-bottom {
  margin-top: 10px;
  text-align: center;
}

.enter-shop {
  display: inline-block;
  font-size: 14px;
  background-color: #f2f5f8;
  width: 150px;
  height: 30px;
  text-align: center;
  line-height: 30px;
  border-radius: 10px;
}
</style>
